
/**
 *
 * @author andrew
 */
package org.chemdraw.atoms;

import java.awt.*;
import org.chemdraw.molecule.*;
import java.util.ArrayList;
import javax.swing.JComponent;
import org.chemdraw.molecule.Molecule;

public abstract class Atom extends JComponent {

    private int atomicNumber;
    private double atomicMass;
    private int valenceElectrons;
    private String name;
    private int charge;


    public Atom(int atomicNumber,
            double atomicMass,
            int valenceElectrons,
            String name)
    {

        this.atomicNumber = atomicNumber;
        this.atomicMass = atomicMass;
        this.valenceElectrons = valenceElectrons;
        this.name = name;
        this.charge = 8 - this.valenceElectrons;
    }

   
    

    //Getters & Setters
    public int getAtomicNumber(){
        return this.atomicNumber;
    }

    public double getMass(){
        return this.atomicMass;
    }

    public int getValenceElectrons(){
        return this.valenceElectrons;
    }

    public String getName(){
        return this.name;
    }

    public void setCharge(int newCharge){
        this.charge = newCharge;
    }



    public Molecule bond(Atom a){
        ArrayList<Atom> atoms = new ArrayList<Atom>();
        atoms.add(this);
        atoms.add(a);
        Molecule m = new Molecule(atoms);
        return m;
    }

    public String toString(){
        return this.getName();
    }

}
